<layout name="Iflayout"/>
<div class="xyh-content">
    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header"><em class="glyphicon glyphicon-cloud-upload"></em>
                产品列表
                <span class="xyh-pos">
                <i class="glyphicon glyphicon-log-out"></i>
                <a href="{:U('Product/index')}">产品展示 </a> <em class="glyphicon glyphicon-menu-right"></em>
                </span>
            </h3>


            <nav class="navbar navbar-default">
                <div class="container-fluid">
                    <div class="navbar-header">
                        <span class="navbar-text">子栏目：</span>
                        <a href="{:U('Product/index')}" class="btn btn-sm btn-default navbar-btn">家具类</a>
                        <a href="{:U('Product/index')}" class="btn btn-sm btn-default navbar-btn">工艺品系列</a>
                    </div>
                </div>
            </nav>
        </div>
    </div>

    <div class="row margin-botton">
        <div class="col-sm-6 column">
            <div class="btn-group btn-group-md">

                <script>
                    $(function () {
                        arr=[]
                        $('#move').click(function () {
                            $('.checkbox:checked').each(function(i){
                                arr[i] = $(this).val();
                            })
                            if(arr!=null&&arr!='') {
                                location.href = "{:U('Product/move')}?id=" + arr.join(',') + "&pid=" + {$_GET['pid']};
                            }else{alert("请选择");}
                        })

                    })
                </script>

                <button class="btn btn-primary" type="button" onclick="goUrl('/xyhai.php?s=/Product/add/pid/5')"><em class="glyphicon glyphicon-plus-sign"></em> 添加产品</button>
                <a><button id="move" class="btn " type="button"><em class="glyphicon glyphicon-th-list"></em> 移动</button></a>
                <a><button class="btn btn-default" type="button" ><em class="glyphicon glyphicon-remove-circle"></em> 删除</button></a>
                <a href="{:U('Product/trach')}"><button class="btn " type="button"><em class="glyphicon glyphicon-trash"></em> 回收站</button></a>

            </div>
        </div>
        <div class="col-sm-6 text-right">
            <form class="form-inline" method="post" action="{:U('Product/index')}">
                <div class="form-group">
                    <label class="sr-only" for="inputKeyword">关键字</label>
                    <input type="text" class="form-control" name="keyword" id="inputKeyword" placeholder="关键字" value="">
                </div>
                <input type="hidden" name="pid" value="5">
                <button type="submit" class="btn btn-default">搜索</button>
            </form>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <form action="" method="post" id="form_do" name="form_do">
                <div class="table-responsive">
                    <table class="table table-hover xyh-table-bordered-out">
                        <thead>
                        <tr class="active">
                            <th><input type="checkbox" id="check"></th>
                            <th>编号</th>
                            <th>标题</th>
                            <th>分类</th>
                            <th>点击数</th>
                            <th>发布时间</th>
                            <th class="text-right">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <foreach name="list" item="arr">
                        <tr>
                            <td><input type="checkbox" name="key[]" value="{$arr['id']}" class="checkbox"></td>

                            <td>{$arr['id']}</td>
                            <td class="aleft" style="color:#ed008c">{$arr['title']}<span style="color:#079B04;">[图片]</span></td>
                            <td>{$arr['name']}</td>
                            <td>{$arr['click']}</td>
                            <td>{$arr['publishtime']|date='Y-m-d H:i:s',###}</td>
                            <td class="text-right">
                                <a href="/index.php?s=/Home/Show/index/cid/7/id/3#1245535567" target="_blank" class="label label-info">查看</a>
                                <a href="{:U('Product/edit',array('id'=>$arr['id'],))}/?cid={$arr.cid}" class="label label-success">编辑</a>
                                <a href="{:U('Product/del',array('id'=>$arr['id']))}"  class="label label-danger">删除</a>
                            </td>
                        </tr>

                        </foreach>


                        </tbody>
                    </table>
                </div>
            </form>

            <div class="row clearfix">
                <div class="col-md-12 column">
                    <div class="xyh-page">
                        <div>
                            <span class="rows">共 {$count}条记录</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<script type="text/javascript">

    $('.btn-default').click(function(){

        if ($('.checkbox:checked').length==0) {
            alert('至少选择一个');
        }else{
            var arr =[];
            $('.checkbox:checked').each(function(i){
                arr[i] = $(this).val();
            })

            if(confirm('确定删除?')) {

                $.post("{:U('Product/del')}", {'id': arr}, function (date) {
                    if (date == 1) {
                        alert('删除成功');
                        //location.href='';
                        $('.checkbox:checked').parent().parent().remove();
                    } else {
                        alert('删除失败');
                    }
                })
            }
        }
    })

</script>


